# _*_ coding : utf-8 _*_
# @Time : 2022/12/26 19:32
# @Author : TANGZZ
# @File : overlay
# @Project : python_game
import pygame
from settings import OVERLAY_POSITIONS


class OverLay:
    def __init__(self, player):
        # surface层的获取
        self.surface = pygame.display.get_surface()
        # 玩家对象获取
        self.player = player

        # 资源导入
        overlay_path = '../resource/graphics/overlay/'
        self.tools_surface = {tool: pygame.image.load(f'{overlay_path}{tool}.png').convert_alpha()
                              for tool in self.player.tools}
        self.seeds_surface = {seed: pygame.image.load(f'{overlay_path}{seed}.png').convert_alpha()
                              for seed in self.player.seeds}

    def display(self):
        tool = self.tools_surface[self.player.selected_tool]
        tool_rect = tool.get_rect(midbottom=OVERLAY_POSITIONS['tool'])
        self.surface.blit(tool, tool_rect)

        seed = self.seeds_surface[self.player.selected_seed]
        seed_rect = seed.get_rect(midbottom=OVERLAY_POSITIONS['seed'])
        self.surface.blit(seed, seed_rect)
